package com.xzsoft.gdwz.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.xzsoft.gdwz.model.ValueBean;
import com.xzsoft.gdwz.services.ValueService;

@Controller
@RequestMapping("/value")
public class ValueController {
	@Autowired
	private ValueService valueService;
	
	@RequestMapping("/getValueByCode")
	public void getValueByCode(HttpServletRequest request,HttpServletResponse response) throws IOException{
		String setCode = request.getParameter("setCode");
		List<ValueBean> list = valueService.getValuesBySetCode(setCode);
		JSONArray array = JSONArray.fromObject(list);
		response.setCharacterEncoding("UTF-8");  
		response.getWriter().println(array.toString());
		response.getWriter().flush();
		response.getWriter().close(); 
	}
}
